package com.xingyue.loginqueryarticle.controllers;


import com.xingyue.loginqueryarticle.Dao.PageDao;
import com.xingyue.loginqueryarticle.Dao.QueryDao;
import com.xingyue.loginqueryarticle.Dao.ServletDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by hdwx on 2016/11/18.
 */
@WebServlet(urlPatterns = "/xingquery")
public class PageQueryuedCtroller extends ServletDao{

    @Override
    public void todo(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String page=req.getParameter("page"); //从前页面获取一个页数
   //
    int pageint= 1; //定义一个当前页数变量
try{
    pageint =Integer.valueOf(page);  //当前页数为获取的页数

}catch(Exception e){

}
        QueryDao dao =new QueryDao();
       PageDao pd= dao.queryPage(pageint);  //调用查询方法 查询页数参数赋值

req.setAttribute("pd",pd);    //定义一个 request 对象变量 赋值Page类

//转发
req.getRequestDispatcher("Page.jsp").forward(req,resp);
    }
}
